package com.example.controller;
import com.example.service.RechargeService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/*
@description:接口幂等
@ClassName RechargeController
@author chen
@create 2025-07-09 22:22
@Version 1.0
*/
@RestController
public class RechargeController
{

    @Resource
    private RechargeService rechargeService;


    /*
     * @param rechargeId
     * @==============History===============<br/>
     * @Description //   充值回调，处理方式1：更新时使用本身状态作为条件判断解决
     * @Date 2025-7-9 22:33
     * @Author < a href="15991488967@163.com">chen</ a>
     * @return 若已处理成功过或处理成功，返回true，否则返回false
     */
    @PostMapping("/rechargeCallBack1")
    public boolean rechargeCallBack1(@RequestParam("rechargeId") String rechargeId)
    {
        return this.rechargeService.rechargeCallBack1(rechargeId);
    }


    /*
     * @param rechargeId
     * @==============History===============<br/>
     * @Description //   充值回调，处理方式2：采用乐观锁解决
     * @Date 2025-7-9 22:34
     * @Author < a href="15991488967@163.com">chen</ a>
     * @return 若已处理成功过或处理成功，返回true，否则返回false
     */
    @PostMapping("/rechargeCallBack2")
    public boolean rechargeCallBack2(@RequestParam("rechargeId") String rechargeId)
    {
        return this.rechargeService.rechargeCallBack2(rechargeId);
    }





    /*
     * @param rechargeId
     * @==============History===============<br/>
     * @Description //   充值回调，处理方式3：使用唯一约束解决
     * @Date 2025-7-9 22:34
     * @Author < a href="15991488967@163.com">chen</ a>
     * @return 若已处理成功过或处理成功，返回true，否则返回false
     */
    @PostMapping("/rechargeCallBack3")
    public boolean rechargeCallBack3(@RequestParam("rechargeId") String rechargeId)
    {
        return this.rechargeService.rechargeCallBack3(rechargeId);
    }



}
